//
//  ZBImageTextViewController.m
//  ZBTechniqueLibrary
//
//  Created by apple on 2018/9/29.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ZBImageTextViewController.h"
#import "ZBAttributeTextLabel.h"

@interface ZBImageTextViewController ()

@property (nonatomic, strong) ZBAttributeTextLabel *fontLabel;

@property (nonatomic, strong) ZBAttributeTextLabel *priceLabel;
@end

@implementation ZBImageTextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"图文混排的Label应用";
    
    //1.大小文字
    [self.view addSubview:self.fontLabel];
    self.fontLabel.frame = CGRectMake(30, 100, 300, 30);
    [self.fontLabel zb_setNoramlText:@"纸上得来终觉浅,绝知此事要躬行" differentFont:[UIFont systemFontOfSize:20.0] normalFont:[UIFont systemFontOfSize:14.0] differentColor:[UIColor blueColor] normalColor:[UIColor blackColor] range:NSMakeRange(0, 5)];
    
    //2、价格
    [self.view addSubview:self.priceLabel];
    self.priceLabel.frame = CGRectMake(30, CGRectGetMaxY(self.fontLabel.frame) + 10, 100, 30);
    [self.priceLabel zb_setPriceNoramlText:@"¥200.34" differentFont:[UIFont systemFontOfSize:14.0] normalFont:[UIFont systemFontOfSize:20.0] normalColor:[UIColor redColor] isLine:NO lineOffset:2];
    
    //3、带线价格
    ZBAttributeTextLabel *priceLineLabel  = [[ZBAttributeTextLabel alloc]init];
    [self.view addSubview:priceLineLabel];
    priceLineLabel.frame = CGRectMake(CGRectGetMaxX(self.priceLabel.frame)+10, CGRectGetMaxY(self.fontLabel.frame) + 10, 100, 30);
    [priceLineLabel zb_setPriceNoramlText:@"¥200.34" differentFont:[UIFont systemFontOfSize:14.0] normalFont:[UIFont systemFontOfSize:20.0] normalColor:[UIColor grayColor] isLine:YES lineOffset:2];
    
    //4、标签
    ZBAttributeTextLabel *tipLabel  = [[ZBAttributeTextLabel alloc]init];
    [self.view addSubview:tipLabel];
    tipLabel.frame = CGRectMake(30, CGRectGetMaxY(self.priceLabel.frame) + 10, 80, 30);
    [tipLabel zb_setTipText:@"高级选择" normalFont:nil normalColor:nil normalBackgroundColor:[UIColor yellowColor] offset:UIOffsetMake(0, 0) cornerRadius:0 borderWidth:0];
    
    ZBAttributeTextLabel *tipLabel2  = [[ZBAttributeTextLabel alloc]init];
    [self.view addSubview:tipLabel2];
    tipLabel2.frame = CGRectMake(CGRectGetMaxX(tipLabel.frame)+30, CGRectGetMaxY(self.priceLabel.frame) + 10, 30, 30);
    [tipLabel2 zb_setTipText:@"其他选择" normalFont:nil normalColor:[UIColor redColor] normalBackgroundColor:[UIColor yellowColor] offset:UIOffsetMake(5, 5) cornerRadius:3 borderWidth:1];
    
    //5、多行文字
    ZBAttributeTextLabel *moreLabel  = [[ZBAttributeTextLabel alloc]init];
    [self.view addSubview:moreLabel];
    moreLabel.frame = CGRectMake(30, CGRectGetMaxY(tipLabel.frame) + 10, 300, 60);
    NSMutableParagraphStyle *paraph = [[NSMutableParagraphStyle alloc]init];
    paraph.lineSpacing = 3;
    [moreLabel zb_setMoreNoramlText:@"9月29日小葱早报 | 阿里巴巴达摩院正式上线区块链实验室；比特币期货9月份跌超5%，第三季度则涨超12%" normalFont:nil normalColor:nil paragraphStyle:paraph];
    
    //6、多行图文文字
    ZBAttributeTextLabel *moreImageLabel  = [[ZBAttributeTextLabel alloc]init];
    [self.view addSubview:moreImageLabel];
    moreImageLabel.numberOfLines = 0;
    moreImageLabel.frame = CGRectMake(30, CGRectGetMaxY(moreLabel.frame) + 10, 300, 60);
    NSMutableParagraphStyle *paraphmoreImage = [[NSMutableParagraphStyle alloc]init];
    paraphmoreImage.lineSpacing = 3;
    [moreImageLabel zb_setImageNoramlText:@"阿里巴巴达摩院正式上线区块链实验室；比特币期货9月份跌超" normalFont:nil normalColor:nil paragraphStyle:paraphmoreImage imageName:@"default_select" imageOffset:-3];
    
    //7.设置阴影文字
    NSShadow *shadow = [[NSShadow alloc] init];
    shadow.shadowBlurRadius = 5.0f; // 模糊度
    shadow.shadowColor = [UIColor redColor];
    shadow.shadowOffset = CGSizeMake(1, 5);
    ZBAttributeTextLabel *shadowLabel  = [[ZBAttributeTextLabel alloc]init];
    [self.view addSubview:shadowLabel];
    shadowLabel.frame = CGRectMake(30, CGRectGetMaxY(moreImageLabel.frame) + 10, 300, 60);
    [shadowLabel zb_setShadowNormalText:@"阴影文字" normalFont:nil normalColor:nil shadow:shadow];
    
    
}



#pragma mark - lazy
-(ZBAttributeTextLabel *)fontLabel
{
    if(_fontLabel == nil)
    {
        _fontLabel = [[ZBAttributeTextLabel alloc]init];
    }
    return _fontLabel;
}

-(ZBAttributeTextLabel *)priceLabel
{
    if(_priceLabel == nil)
    {
        _priceLabel = [[ZBAttributeTextLabel alloc]init];
    }
    return _priceLabel;
}




@end
